package org.example.springlogin.result;

import lombok.Data;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 九转苍翎
 * Date: 2025/10/16
 * Time: 19:22
 */
@Data
public class Result<T> {
    //业务码
    private ResultStatus code;
    //错误信息
    private String error;
    //数据
    private T data;

    public static <T> Result<T> success(T data) {
        Result<T> result = new Result<>();
        result.setCode(ResultStatus.SUCCESS);
        result.setError(null);
        result.setData(data);
        return result;
    }

    public static <T> Result<T> fail(String error) {
        Result<T> result = new Result<>();
        result.setCode(ResultStatus.FAIL);
        result.setError(error);
        result.setData(null);
        return result;
    }
}
